#include <bits/stdc++.h>
using namespace std;

const int kInf = 1e9;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T;

  for (cin >> T; T; T--) {
    string a, b, c;
    int n, m;

    cin >> a >> b >> c;
    n = a.size(), m = b.size();

    vector<vector<int>> dp(n + 1, vector<int>(m + 1, kInf));

    dp[0][0] = 0;
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= m; j++) {
        if (i < n) {
          dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (a[i] != c[i + j]));
        }
        if (j < m) {
          dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (b[j] != c[i + j]));
        }
      }
    }
    cout << dp[n][m] << "\n";
  }
  return 0;
}